package com.yx.study.leet.primary.tree;

import com.yx.study.leet.utils.TreeNode;

/**
 * 最大深度
 * https://leetcode.cn/leetbook/read/top-interview-questions-easy/xnd69e/
 */
public class MaxDepth {
    public int maxDepth(TreeNode root) {
        // 递归 只是获取子树的深度，需要加上根结点
        return root == null ? 0 : Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
    }
}
